<?php
foreach($partnerlang as $langkey=>$langval){
    $title[$langkey] = (set_value('title'.$langkey) == '')?$mainmenudetails['title'.$langkey]:set_value('title'.$langkey);
    $shortdesc[$langkey] = (set_value('shortdesc'.$langkey) == '')?$mainmenudetails['shortdesc'.$langkey]:set_value('shortdesc'.$langkey);
    $desc[$langkey] = (set_value('desc'.$langkey) == '')?$mainmenudetails['desc'.$langkey]:set_value('desc'.$langkey);    
}
$customlinks_id = (set_value('customlinks_id') == '')?$mainmenudetails['customlinks_id']:set_value('customlinks_id');
$status = (set_value('status') == '')?$mainmenudetails['status']:set_value('status');

$id = ($this->input->post('id') == '')?$mainmenudetails['mainmenu_id']:$this->input->post('id');
$action=(($mainmenudetails['id'] || $this->input->post('id')!='')?"doaddmainmenu":"doaddmainmenu");
?>

<?php
//$set_txtContactName = (set_value('txtContactName') == '')?$hoteldetails['txtContactName']:set_value('txtContactName');
?>
<div class="form_content">
    <header><h3>Add New List Items for Custom Links</h3></header>
    <div class="module_content">
        <?php if($image_deleted):?>
        <div class="error"><?php echo $image_deleted; ?></div>
        <?php endif;?>
        <?php //echo validation_errors(); ?>
        <form name="mainmenuform" id="mainmenuform"  action="<?php echo base_url(); ?>secu/mainmenu/<?php echo $action;?>" method="post" onsubmit="return validateForm()" >
        <input type="hidden" name="id" id="id" value="<?php echo $id; ?>">
        <fieldset>
            <label style="width: 25%;">Custom Links Page Name</label>
            <select name="customlinks_id" id="customlinks_id" style="width: 220px;">
                <option value="">Select Custom Links Page</option>
                <?php foreach ($customlinks_type_arr as $val) :?>                    
                <option value="<?php echo $val['customlinks_id']; ?>" <?php echo (($customlinks_id==$val['customlinks_id'] || $customlinks_id_reload==$val['customlinks_id'])?"selected=selected":"")?>><?php echo $val['customlinks_page_name']; ?> - <?php echo substr($val['title'], 0); ?></option>
                <?php endforeach; ?>
            </select>
             <?php echo form_error('customlinks_id'); ?>
        </fieldset>
        <?php foreach($partnerlang as $langkey=>$langval):?>
        <fieldset>          
            <label> Menu Page Title (<?php echo $langval;?>)</label>
            <input type="text" name="title<?php echo $langkey?>" id="title<?php echo $langkey?>" value="<?php echo $title[$langkey] ?>" />        
        </fieldset>
        <?php endforeach;?>
        <?php foreach($partnerlang as $langkey=>$langval):?>
        <fieldset>          
            <label> Short Description (<?php echo $langval;?>)</label>
            <textarea name="shortdesc<?php echo $langkey?>" id="shortdesc<?php echo $langkey?>"><?php echo $shortdesc[$langkey] ?></textarea> 
        </fieldset>
        <?php endforeach;?>
        <?php foreach($partnerlang as $langkey=>$langval):?>
        <fieldset>
            <label>Description (<?php echo $langval;?>):</label>
            <!--<textarea rows="4" name="txtHdescriptions<?php //echo $langkey?>" id="txtHdescriptions<?php //echo $langkey?>" /></textarea>-->
            <div style="padding: 0 0 0 10px;">
            <?php $this->editorfck->load('desc' . $langkey, $desc[$langkey], '95%', 300, 'Default'); ?>
            </div>
        </fieldset>
        <?php endforeach;?>    
        <fieldset style="width:40%;">
            <label style="width: 10%;">Status</label>
            <input <?php echo ($status==1)?"checked":""; ?> type="checkbox" name="status" value="1" style="width:20%;">
             <?php echo form_error('status'); ?>
        </fieldset>
        <fieldset>
            <input type="submit" name="submit" id="submit" value="SAVE"  >&nbsp;
            <input type="reset" name="reset" id="reset" value="RESET" >
        </fieldset>
        
        <div class="clear"></div>
        </form>
<?php if ($id!=''):?>
        <div class="clear"></div>
        <form enctype="multipart/form-data" id="fupload" method="post" action="<?php echo base_url(); ?>secu/mainmenu/savemainmenuimages/mainmenuimg">
            <input type="hidden" name="id" value="<?php echo $id;?> " id="id">
            <input type="hidden" name="upload_from" value="mainmenuimg" id="upload_from">
            <a name="img"></a>
            <fieldset style="width:50%; float:left; padding: 10px 0 10px 10px;">
            <input name="userfile" type="file" size="40"/>
            <input type="submit" name="btn_upload" value="Upload &uarr;" class="btnupload"/>
            </fieldset>
            <?php if (isset ($imgerror)) { ?>
            <div class="error"><?php echo $imgerror; ?></div>
            <?php } ?>

        </form>
        <div class="clear"></div>
        <fieldset style="padding: 10px; width:200px">
        <?php if($mainmenudetails['image']) { ?>

                    <div class="imgbox">
                        <a class=""  href="<?php echo base_url(); ?>images/uploads/original/<?php echo $mainmenudetails['image'] ?>">
                        <img class="thumb" name="thumb" id="" src="<?php echo base_url(); ?>images/uploads/thumb/thumb_<?php echo $mainmenudetails['image'] ?>"/>
                        </a>
                        <div>
                            <a class="adel" href="<?php echo base_url()?>secu/mainmenu/deletemainmenuimage/name/<?php echo $mainmenudetails['image']; ?>/id/<?php echo $mainmenudetails["mainmenu_id"] ;?>">
                            <img src="<?php echo base_url(); ?>images/admin/icn_trash.png" title="Trash">delete
                            </a>
                        </div>
                    </div>

                <?php } ?>
            </fieldset>
                <div class="clear"></div>
        <?php endif; ?>   
    </div>



</div>
<!--<script type="text/javascript">
$("#customlinks_id").change(function(){
    if ($(this).val()!=''){
    var url = '<?php echo base_url()?>/secu/mainmenu/loadcustompagewisedetails/id/'+$(this).val();    
    $(location).attr('href',url);
    }
});
</script>-->
